FUNCTION ZFIFM_INV_CHECK_LIST_NEW.
*"----------------------------------------------------------------------
*"*"本地接口：
*"  IMPORTING
*"     VALUE(IS_CONTENT) TYPE  ZCL_DT_INVOICE_CHECK_LIST_NEW2
*"  EXPORTING
*"     VALUE(ES_MSG) TYPE  BAPIRET2
*"     VALUE(EV_TASK_NO) TYPE  STRING
*"  TABLES
*"      RETURN STRUCTURE  BAPIRET2 OPTIONAL
*"----------------------------------------------------------------------
  DATA:
    LO_PI    TYPE REF TO ZCL_CO_SI_SAP2NONO_INVOICECHEC,
    LS_OUT   TYPE ZCL_MT_INVOICE_CHECK_LIST_NEW1,
    LS_INPUT TYPE ZCL_MT_INVOICE_CHECK_LIST_NEW.

  DATA:
    LV_UUID_C32 TYPE SYSUUID_C32,
    LV_TS       TYPE STRING.

  DATA:
    LS_INV_DATA TYPE ZCL_DT_INVOICE_CHECK_LIST_NEW1,
    LT_INV_DATA TYPE ZCL_DT_INVOICE_CHECK_LIST__TAB.

  ZIRPSAVE1: 'ZFIFM_INV_CHECK_LIST_NEW'. "Log

  CLEAR ES_MSG.
  CLEAR EV_TASK_NO.
  PERFORM FRM_GET_CONFIG CHANGING ES_MSG.
  IF ES_MSG-TYPE = 'E'.

    APPEND ES_MSG TO RETURN.
    ZIRPSAVE2: CX_R SPACE.
    RETURN.
  ENDIF.

  TRY .
      CREATE OBJECT LO_PI.
    CATCH CX_AI_SYSTEM_FAULT INTO DATA(LR_CX_AI).
      ES_MSG-TYPE = 'E'.
      ES_MSG-MESSAGE = LR_CX_AI->GET_TEXT( ).

      APPEND ES_MSG TO RETURN.
      ZIRPSAVE2: CX_R SPACE.
      RETURN.
  ENDTRY.


  " 获取GUID
  CLEAR:LV_UUID_C32.
  GO_TAX->GET_GUID( IMPORTING EV_GUID_32 = LV_UUID_C32 ).
  " 获取时间戳
  CLEAR:LV_TS.
  GO_TAX->GET_TIMESTAMP( IMPORTING EV_TS = LV_TS ).


  TRY .
*&----------公有参数(消息头)
      LS_OUT-MT_INVOICE_CHECK_LIST_NEW_REQ-CONTENT_TYPE    = ''.
      LS_OUT-MT_INVOICE_CHECK_LIST_NEW_REQ-X_NUONUO_SIGN   = ''.
      LS_OUT-MT_INVOICE_CHECK_LIST_NEW_REQ-ACCESS_TOKEN    = GO_TAX->MS_ZFIT043-ZTOKEN.
      LS_OUT-MT_INVOICE_CHECK_LIST_NEW_REQ-TOKEN           = GO_TAX->MS_ZFIT043-ZTOKEN.
      LS_OUT-MT_INVOICE_CHECK_LIST_NEW_REQ-TAXNUM          = GO_TAX->MS_ZFIT043-ZTAXNUM.
      LS_OUT-MT_INVOICE_CHECK_LIST_NEW_REQ-USER_TAX        = GO_TAX->MS_ZFIT043-ZTAXNUM.
      LS_OUT-MT_INVOICE_CHECK_LIST_NEW_REQ-METHOD          = 'nuonuo.OpeMplatform.invoiceCheckListNew'.
*&----------公有参数(消息体)
      LS_OUT-MT_INVOICE_CHECK_LIST_NEW_REQ-SENID           = LV_UUID_C32.
      LS_OUT-MT_INVOICE_CHECK_LIST_NEW_REQ-NONCE           = '503208179'.
      LS_OUT-MT_INVOICE_CHECK_LIST_NEW_REQ-TIMESTAMP       = LV_TS.
      LS_OUT-MT_INVOICE_CHECK_LIST_NEW_REQ-APP_KEY         = GO_TAX->MS_ZFIT043-ZAPPKEY.
      LS_OUT-MT_INVOICE_CHECK_LIST_NEW_REQ-APPKEY          = GO_TAX->MS_ZFIT043-ZAPPKEY.
      LS_OUT-MT_INVOICE_CHECK_LIST_NEW_REQ-APP_SECRET      = GO_TAX->MS_ZFIT043-ZAPPSECRET. "必填
*&---------私有参数
      " 数电平台登录账号

      IF IS_CONTENT IS INITIAL.
        LS_OUT-MT_INVOICE_CHECK_LIST_NEW_REQ-CONTENT-GX_USER_NAME = 'VIM'.

        CLEAR LS_INV_DATA.
        LS_INV_DATA-INVOICE_NUM = '24112000000176653933'.
        APPEND LS_INV_DATA TO LT_INV_DATA.
        LS_OUT-MT_INVOICE_CHECK_LIST_NEW_REQ-CONTENT-INV_DATA = LT_INV_DATA[].

      ELSE.
        LS_OUT-MT_INVOICE_CHECK_LIST_NEW_REQ-CONTENT = IS_CONTENT.
      ENDIF.

      CALL METHOD LO_PI->SI_SAP2NONO_INVOICECHECKLISTNE
        EXPORTING
          OUTPUT = LS_OUT
        IMPORTING
          INPUT  = LS_INPUT.

      CONDENSE LS_INPUT-MT_INVOICE_CHECK_LIST_NEW_RES-CODE.

      IF LS_INPUT-MT_INVOICE_CHECK_LIST_NEW_RES-CODE = GC_NONO_RET_CODE_E0000.
        ES_MSG-TYPE = 'S'.
        ES_MSG-MESSAGE = '成功发起勾选抵扣'(T06).
        "EV_TASK_NO = LS_INPUT-MT_INVOICE_CHECK_LIST_NEW_RES-RESULT-TASK_NO.

      ELSE.
        ES_MSG-TYPE = 'E'.
        ES_MSG-MESSAGE = LS_INPUT-MT_INVOICE_CHECK_LIST_NEW_RES-DESCRIBE.
        EXIT.
      ENDIF.


    CATCH CX_ROOT INTO DATA(LR_ERROR).
      ES_MSG-TYPE = 'E'.
      ES_MSG-MESSAGE =  LR_ERROR->GET_TEXT( ).

      EXIT.
  ENDTRY.

  APPEND ES_MSG TO RETURN.
  ZIRPSAVE2: CX_R SPACE.

ENDFUNCTION.
